#ifndef CV_TOOLS_H
#define CV_TOOLS_H

#include "include/opencv/highgui.h"

int saveAsQuality(char* inputfile, char* outputfile, int quality) {
	IplImage *img;
	int p[3];
	if (quality > 0) {
		img = cvLoadImage(inputfile, CV_LOAD_IMAGE_UNCHANGED);
		p[0] = CV_IMWRITE_JPEG_QUALITY;
		p[1] = quality;
		p[2] = 0;
		cvSaveImage(outputfile, img, p);
		cvReleaseImage(&img);
	}
	return 0;
}

#endif